﻿using System;
using Enyim.Caching;
using Ayatta.Contract;
using System.Web.Mvc;
using System.Web.WebPages;
using Web.Base.Extensions;
using Web.Manage.Controllers;
using Web.Manage.Areas.Game.Models;

namespace Web.Manage.Areas.Game.Controllers
{
    public class UserController : AdminBaseController
    {

        public UserController(ILogService logService, IBaseService baseService, IExtraService extraService, IStoreService storeService, IOrderService orderService, IGameService gameService, IAuctionService auctionService, IPassportService passportService, IPaymentService paymentService, IMemcachedClient memcachedClient)
            : base(logService, baseService, extraService, storeService, orderService, gameService, auctionService, passportService, paymentService, memcachedClient)
        {
        }

        public ActionResult Index(int page = 1, int size = 20, string uid = null, int gameId = 0, int serverId = 0, int? level = null)
        {
            var model = new UserControllerModel.Index();
            model.Uid = uid;

            var userId = uid.AsInt();
            var guid = uid.As<Guid?>();
            if (guid == null)
            {
                uid = string.Empty;
            }

            model.GameId = gameId;
            model.ServerId = serverId;
            model.Level = level;
            model.Games = GetGames();
            model.Users = GameService.GetPagedGameUsers(page, size, userId, uid, gameId, serverId, level??0).ToPagedList(page, size);
            return View(model);
        }

    }
}
